home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscDragViews / MiscDVInspector.m < prev    next >
Encoding:
Text File  |  1995-10-16  |  2.7 KB  |  127 lines

  1. /***************************************************************************
  2.  * CLASS:        MiscDVInspector (MiscDragViewInspector)
  3.  * Copyright (C) 1995 Robert Todd Thomas
  4.  * Use is governed by the MiscKit license
  5.  * 
  6.  *    See the header file for more info about this class.
  7.  ***************************************************************************/
  8.  
  9. #import "MiscViews.subproj/MiscIconWell.h"
  10. #import "MiscDVInspector.h"
  11.  
  12.  
  13. @implementation MiscDVInspector
  14.  
  15. // Load the Inspector.
  16.  
  17. - init
  18. {
  19.     char buf[MAXPATHLEN + 1];
  20.     id bundle;
  21.     
  22.     [super init];
  23.     
  24.     bundle = [NXBundle bundleForClass:[MiscDragView class]];
  25.  
  26.     [bundle getPath: buf forResource: "MiscDVInspector" ofType:"nib"];
  27.  
  28.     [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
  29.            
  30.     return self;
  31. }
  32.  
  33.  
  34.  
  35. // This is called to set the options located on the inspector to
  36. // be the same as the current selected object.
  37.  
  38. - revert: sender
  39. {    
  40.     // set all the radio buttons for dragging options
  41.     
  42.     [ [optionMatrix cellAt: 0 :0] setState:[object allowSourceDragging] ];    
  43.        [ [optionMatrix cellAt: 1 :0] setState:[object allowDestinationDragging] ];    
  44.     [optionMatrix display];    // get matrix to redisplay values
  45.  
  46.     // set icon stuff
  47.  
  48.     [ [iconMatrix cellAt: 1 :0] setEnabled:[object allowDestinationDragging] ];
  49.  
  50.     [ [iconMatrix cellAt: 0 :0] setStringValue:[object imageName] ];
  51.     [ [iconMatrix cellAt: 1 :0] setStringValue:[object acceptingImageName] ];
  52.  
  53.     // set the border type
  54.     
  55.     [borderMatrix selectCellWithTag: [object borderType] ];
  56.     [borderMatrix display];
  57.         
  58.     return [super revert:sender];
  59. }
  60.  
  61.  
  62.  
  63. // This method is called when one of the radio buttons in the inspector
  64. // is clicked. The object is then notified of the change so that
  65. // it can change it's state.
  66.  
  67. - optionsChanged: sender
  68. {
  69.   BOOL  state = [ [sender selectedCell] state];
  70.   
  71.       switch ([ [sender selectedCell] tag])
  72.     {
  73.       case 0:                    
  74.           [object setAllowSourceDragging: state];
  75.         break;
  76.       case 1:                     
  77.           [object setAllowDestinationDragging: state];
  78.         break;
  79.      }
  80.     [window disableFlushWindow];
  81.     [self revert: sender];
  82.     [window reenableFlushWindow];
  83.     return [super ok: sender];
  84. }
  85.  
  86. - iconsChanged: sender
  87. {    const char *str;
  88.     if(str=[[iconMatrix cellAt: 0 :0] stringValue])
  89.         [object setImageByName:str];
  90.     if(str=[[iconMatrix cellAt: 1 :0] stringValue])
  91.         [object setAcceptingImageByName:str];
  92.     return [super ok: sender];
  93. }
  94.  
  95. - borderChanged: sender
  96. {
  97.     [object setBorderType: [ [borderMatrix selectedCell] tag] ];
  98.     [object display];
  99.     
  100.     return [super ok: sender];
  101. }
  102.  
  103.  
  104.  
  105. // Determines whether the inspector panel will have an "OK" and
  106. // "Revert" button. 
  107.  
  108. - (BOOL)wantsButtons
  109. {
  110.     return NO;
  111. }
  112.  
  113.  
  114. @end
  115.  
  116.  
  117. @implementation MiscDragView (IBInspector)
  118.  
  119. - (const char *)getInspectorClassName
  120. {
  121.     return "MiscDVInspector";
  122. }
  123.  
  124. @end
  125.  
  126.  
  127.